*Replication do files for Bader and Daxecker, A Chinese resource curse? The human rights effects of oil export dependence on China versus the United States, JPR forthcoming*
*FIgures 1-3*

**Generating descriptive figures 1-3**

*Figure 1, per capita Exports to China and Human Rights*
 **Examine who Chinas biggest per capita suppliers are*
sort ccode
by ccode: egen meanOilcap=mean(Choil_constcap)
gsort meanOilcap
list country ccode meanOilcap if meanOilcap!=. & year==2010

	

*Draw line graphs and combine them*

label var Choil_constcap "Exports to China in US$/c"
label var physint "Physical integrity rights"
twoway (line Choil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Oman" & year>1993, title(Oman) yscale(off axis(2)) legend(off) fxsize(40) scheme(lean1)
gr save ".graphCh1.gph", replace
twoway (line Choil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Equatorial Guinea" & year>1993,  fxsize(30) title(Equatorial Guinea) yscale(off axis(1)) yscale(off axis(2)) scheme(lean1) legend(off)
gr save ".graphCh2.gph", replace
twoway (line Choil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Kuwait" & year>1993,  title(Kuwait) fxsize(30) legend(off)  scheme(lean1) yscale(off axis(1)) yscale(off axis(2))
gr save ".graphCh3.gph", replace
twoway (line Choil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Brunei" & year>1993,  title(Brunei)  legend(off)  fxsize(35) scheme(lean1) yscale(off axis(1)) 
gr save ".graphCh4.gph", replace
twoway (line Choil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Angola" & year>1993, title(Angola)  legend(off) fxsize(40)  scheme(lean1)  yscale(off axis(2))
gr save ".graphCh5.gph", replace
twoway (line Choil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Congo, Republic of" & year>1993, title(Congo)  legend(off)  scheme(lean1) fxsize(30) yscale(off axis(1)) yscale(off axis(2))
gr save ".graphCh6.gph", replace
twoway (line Choil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Saudi Arabia" & year>1993, title(Saudi Arabia)  legend(off)  scheme(lean1) fxsize(30) yscale(off axis(1)) yscale(off axis(2))
gr save ".graphCh7.gph", replace
twoway (line Choil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Qatar" & year>1993,  title(Qatar)  legend(off)  scheme(lean1) fxsize(35) yscale(off axis(1)) 
gr save ".graphCh8.gph", replace
twoway (line Choil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="United Arab Emirates" & year>1993, title(United Arab Emirates)  legend(off) fxsize(40)  scheme(lean1) yscale(off axis(2))
gr save ".graphCh9.gph", replace
twoway (line Choil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Libya" & year>1993,   title(Libya)  legend(off)  scheme(lean1) fxsize(30) yscale(off axis(1)) yscale(off axis(2))
gr save ".graphCh10.gph", replace
twoway (line Choil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Gabon" & year>1993,   title(Gabon)  legend(off)  scheme(lean1) fxsize(30) yscale(off axis(1)) yscale(off axis(2))
gr save ".graphCh11.gph", replace
twoway (line Choil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Yemen" & year>1993,   title(Yemen) legend(off)  scheme(lean1) fxsize(35) yscale(off axis(1)) 
gr save ".graphCh12.gph", replace

graph combine ".graphCh1.gph" ".graphCh2.gph" ".graphCh3.gph" ".graphCh4.gph" ".graphCh5.gph" ".graphCh6.gph" ".graphCh7.gph" ".graphCh8.gph" ".graphCh9.gph" ".graphCh10.gph" ".graphCh11.gph" ".graphCh12.gph",  scheme(lean1) ycommon rows(3) imargin(0 0.7 1 1)

	graph save "combinationCh1.gph", replace
graph export "/biggest suppliers CH.pdf", as(pdf) replace

drop meanOilcap

*Figure 2, Per capita exports to US and Human RIghts*
drop meanOilcapUS
sort ccode
by ccode: egen meanOilcapUS=mean(USoil_constcap) 
gsort meanOilcapUS
list country ccode meanOilcapUS if meanOilcapUS!=. & year==2010


label var USoil_constcap "Exports to USA in US$/c"
label var physint "Physical integrity rights"


twoway (line USoil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Trinidad and Tobago" & year>1993, title(Trinidad and Tobago)  yscale(off axis(2)) legend(off) fxsize(40) scheme(lean1)
gr save ".graphUS1.gph", replace
twoway (line USoil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Gabon" & year>1993,   title(Gabon)  yscale(off axis(1)) yscale(off axis(2)) scheme(lean1) legend(off) fxsize(30)
gr save ".graphUS2.gph", replace
twoway (line USoil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Kuwait" & year>1993,  title(Kuwait)  yscale(off axis(1)) yscale(off axis(2)) scheme(lean1) legend(off) fxsize(30)
gr save ".graphUS3.gph", replace
twoway (line USoil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Canada" & year>1993, title(Canada)  legend(off)   scheme(lean1) fxsize(35) yscale(off axis(1))
gr save ".graphUS4.gph", replace
twoway (line USoil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Equatorial Guinea" & year>1993, title(Equatorial Guinea)  yscale(off axis(2)) legend(off) fxsize(40) scheme(lean1)
gr save ".graphUS5.gph", replace
twoway (line USoil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Saudi Arabia" & year>1993,  title(Saudi Arabia)  yscale(off axis(1)) yscale(off axis(2)) scheme(lean1) legend(off) fxsize(30)
gr save ".graphUS6.gph", replace
twoway (line USoil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Venezuela" & year>1993, title(Venezuela) yscale(off axis(1)) yscale(off axis(2)) scheme(lean1) legend(off) fxsize(30)
gr save ".graphUS7.gph", replace
twoway (line USoil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Norway" & year>1993,  title(Norway)  legend(off)   scheme(lean1) fxsize(35) yscale(off axis(1))
gr save ".graphUS8.gph", replace
twoway (line USoil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Bahamas" & year>1993, title(Bahamas)  yscale(off axis(2)) legend(off) fxsize(40) scheme(lean1)
gr save ".graphUS9.gph", replace
twoway (line USoil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Angola" & year>1993,  title(Angola) yscale(off axis(1)) yscale(off axis(2)) scheme(lean1) legend(off) fxsize(30)
gr save ".graphUS10.gph", replace
twoway (line USoil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Brunei" & year>1993,  title(Brunei)  yscale(off axis(1)) yscale(off axis(2)) scheme(lean1) legend(off) fxsize(30)
gr save ".graphUS11.gph", replace
twoway (line USoil_constcap year, sort) (line physint year, clpat(dash)  sort yaxis(2)) if country=="Congo, Republic of" & year>1993,  title(Republic of Congo) legend(off)   scheme(lean1) fxsize(35) yscale(off axis(1))
gr save ".graphUS12.gph", replace


graph combine ".graphUS1.gph" ".graphUS2.gph" ".graphUS3.gph" ".graphUS4.gph" ".graphUS5.gph" ".graphUS6.gph" ".graphUS7.gph" ".graphUS8.gph" ".graphUS9.gph" ".graphUS10.gph" ".graphUS11.gph" ".graphUS12.gph",  ycommon rows(3) imargin(1 1 1 1) scheme(lean1)

	graph save "combinationUS1.gph", replace
graph export "/biggest per capita suppliers US.pdf", as(pdf) replace

drop meanOilcapUS


*Figure 3, marginal effects model 1 table 1"

label var lnUSoil_constcaplag "Exports to USA in US$/c (ln)"
label var lnChoil_constcaplag "Exports to China in US$/c (ln)"

xi: ologit  physint physintlag   lnChoil_constcaplag lnUSoil_constcaplag demodummylag     lngdplag lnpoplag incidencev412 i.year if year>1991, cluster(ccode)
margins , at(lnUSoil_constcaplag=(0 (0.5) 8.5) )  atmeans pr(outcome(7)) 
marginsplot, x(lnUSoil_constcaplag ) xlab(0 (2) 8) plotopts(msymbol(none)) ciopts(lpattern(-)) recastci(rline) title("") scheme(lean1) saving(marg1, replace)
margins  , at(lnChoil_constcaplag=(0 (0.5) 8.5) ) atmeans pr(outcome(7)) 
marginsplot, x(lnChoil_constcaplag ) xlab(0 (2) 8) plotopts(msymbol(none)) ciopts(lpattern(-)) title("") recastci(rline) scheme(lean1) saving(marg2, replace)
gr combine marg1.gph marg2.gph, ycommon scheme(lean1)
